Computer Science Related Others Courses AvailableThe Best Codder.blogspot.com
Posts

SciPy Spatial Data

1 min read

 

SciPy Spatial Data

Working with Spatial Data

Spatial data refers to data that is represented in a geometric space.

E.g. points on a coordinate system.

We deal with spatial data problems on many tasks.

E.g. finding if a point is inside a boundary or not.

SciPy provides us with the module scipy.spatial, which has functions for working with spatial data.


Triangulation

A Triangulation of a polygon is to divide the polygon into multiple triangles with which we can compute an area of the polygon.

A Triangulation with points means creating surface composed triangles in which all of the given points are on at least one vertex of any triangle in the surface.

One method to generate these triangulations through points is the Delaunay() 

Triangulation.

Example

Create a triangulation from following points:

import numpy as np
from scipy.spatial import Delaunay
import matplotlib.pyplot as plt

points = np.array([
  [24],
  [34],
  [30],
  [22],
  [41]
])

simplices = Delaunay(points).simplices

plt.triplot(points[:, 0], points[:, 1], simplices)
plt.scatter(points[:, 0], points[:, 1], color='r')

plt.show()

Result:

You may like these posts

  •  Structuring Python ProgramsPython Statements In general, the interpreter reads and executes the statements line by line i.e sequentially. Though, there are some statemen…
  •  Taking multiple inputs from user in PythonThe developer often wants a user to enter multiple values or inputs in one line. In C++/C user can take multiple inputs in one line …
  • Taking input in Python Developers often have a need to interact with users, either to get data or to provide some sort of result. Most programs today use a dialog box as a way…
  •  (Strings, Lists, Tuples, Iterations)Strings in Python: A string is a sequence of characters that can be a combination of letters, numbers, and special characters. It can…
  •  Taking input from console in PythonWhat is Console in Python? Console (also called Shell) is basically a command line interpreter that takes input from the user i.e one …
  •  Statement, Indentation and Comment in PythonStatementsInstructions written in the source code for execution are called statements. There are different types of statements in …

Post a Comment

© 2025Python . The Best Codder All rights reserved. Distributed by